//
//  MeetingTrailerFromTableViewCell.m
//  Gxj
//
//  Created by 刘伟 on 2017/9/2.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "MeetingTrailerFromTableViewCell.h"
#import "MeetingTrailerFromView.h"

@interface MeetingTrailerFromTableViewCell ()<UIGestureRecognizerDelegate>
{
    MeetingTrailerFromView *_meetingTrailerView;
}
@property(nonatomic, strong) UIScrollView * demoContainerView;

@end

@implementation MeetingTrailerFromTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self showMeetingTrailerView];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
}

- (void)showMeetingTrailerView
{
    //创建滚动视图
    _demoContainerView=[[UIScrollView alloc] initWithFrame:CGRectMake(0, kHeightScale(0), UIScreenWidth, kHeightScale(207))];
    //滚动视图的位置
    _demoContainerView.contentSize = CGSizeMake(kWidthScale(1150),kHeightScale(199));
    //_demoContainerView.backgroundColor=[UIColor blueColor];
    //是否可以滚动
    _demoContainerView.scrollEnabled = YES;
    //是否可以整夜滚动
    _demoContainerView.pagingEnabled = NO;
    //水平滚动条
    _demoContainerView.showsHorizontalScrollIndicator = YES;
    
    UITapGestureRecognizer * privateLetterTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAvatarView:)];
    privateLetterTap.numberOfTouchesRequired = 1; //手指数
    privateLetterTap.numberOfTapsRequired = 1; //tap次数
    privateLetterTap.delegate= self;
    
    for (int i = 0 ; i < 5; i++) {
        _meetingTrailerView = [[MeetingTrailerFromView alloc] initWithFrame:CGRectMake(0, kWidthScale(0), kWidthScale(278), kHeightScale(172))];
        
        _meetingTrailerView.backgroundColor = [UIColor colorWithRed:251.0/255.0 green:251.0/255.0 blue:251.0/255.0 alpha:1];
        _meetingTrailerView.layer.cornerRadius = kWidthScale(12);
        _meetingTrailerView.layer.masksToBounds = YES;
        
        [_meetingTrailerView addGestureRecognizer:privateLetterTap];
        self.grabBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        self.grabBtn = (UIButton *)_meetingTrailerView.grabBtn;
        
        UITapGestureRecognizer *r5 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doTapChange:)];
        r5.numberOfTapsRequired = 1;
        [_meetingTrailerView addGestureRecognizer:r5];
        
        // 阴影View
        UIView *shadowView = [[UIView alloc]initWithFrame:CGRectMake(kWidthScale(15)+kWidthScale(288)*i, kWidthScale(10), kWidthScale(278), kHeightScale(172))];
        shadowView.layer.shadowColor = [UIColor blackColor].CGColor;
        shadowView.layer.shadowOffset = CGSizeMake(0, 1);
        shadowView.layer.shadowOpacity = 0.5;
        shadowView.clipsToBounds = NO;
        [shadowView addSubview:_meetingTrailerView];
        _meetingTrailerView.layer.shadowOffset = CGSizeMake(0, 0);
        [_demoContainerView addSubview:shadowView];
    }
    [self.contentView addSubview:self.demoContainerView];
}

//点击
-(void)doTapChange:(UITapGestureRecognizer *)sender{
    if (self.clickTrailerMeeting) {
        self.clickTrailerMeeting(@"1");
    }
}

- (void)tapAvatarView:(UITapGestureRecognizer *)gesture
{
    [self.delegate clickTouchGrab:gesture];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
